<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <div th:include="header::common_resource"></div>
    <style type="text/css">
        html, body {
            width: 100%;
            height: 100%;
            background-image: linear-gradient(120deg, #84fab0 0%, #8fd3f4 100%);
        }
        .container{
            width: 420px;
            height: 320px;
            min-height: 320px;
            max-height: 320px;
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            margin: auto;
            padding: 20px;
            z-index: 130;
            border-radius: 8px;
            background-color: #fff;
            box-shadow: 0 3px 18px rgba(100, 0, 0, .5);
            font-size: 16px;
        }

        .layui-input{
            border-radius: 5px;
            width: 300px;
            height: 40px;
            font-size: 15px;
        }
        .layui-form-item{
            margin-left: -20px;
        }
        #logoid{
            margin-top: -16px;
            padding-left:150px;
            padding-bottom: 15px;
        }
        .layui-btn{
            margin-left: -50px;
            border-radius: 5px;
            width: 350px;
            height: 40px;
            font-size: 15px;
        }
        .verity{
            width: 120px;
        }
        a:hover{
            text-decoration: underline;
        }


    </style>
</head>
<body>
    <form class="layui-form" action="" method="post" id="formId">
        <div class="container">
            <div class="layui-form-mid layui-word-aux">
                <img id="logoid" src="/static/image/06.png" height="35">
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input type="text" name="username" required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密 &nbsp;&nbsp;码</label>
                <div class="layui-input-inline">
                    <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">验证码</label>
                    <div class="layui-input-inline">
                        <input type="text" name="code" required  lay-verify="required" placeholder="请输入验证码" autocomplete="off" class="layui-input verity">

                    </div>
                </div>
                <div class="layui-inline">
                    <img id="verifyCodeId" src="/auth/code" onclick="refresh()"/>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input class="layui-btn" lay-submit lay-filter="formDemo" onclick="submitForm()" value="登录" readonly/>
                </div>
            </div>
        </div>
    </form>
    <script>
        function refresh() {
            $('#verifyCodeId').attr('src', '/auth/code?' + Math.random());
        }

        function submitForm() {
            $.post(
                '/user/login',
                $('#formId').serialize(),
                function (result) {
                    console.log(result);
                    if (result.ok) {
                        mylayer.okUrl(result.msg, '/');
                    } else {
                        mylayer.errorMsg(result.msg);
                        refresh();
                    }
                },
                'json'
            );
        }
    </script>
</body>
</html>